package com.ecnucs.shortlink;


import com.ecnucs.shortlink.common.ShortLinkException;
import com.ecnucs.shortlink.config.ShortLinkConfiguration;
import com.ecnucs.shortlink.utils.ShortLinkTemplate;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableConfigurationProperties(ShortLinkConfiguration.class)
public class ShortLinkAutoConfiguration {
    private final ShortLinkConfiguration shortLinkConfiguration;

    public ShortLinkAutoConfiguration(ShortLinkConfiguration shortLinkConfiguration) {
        this.shortLinkConfiguration = shortLinkConfiguration;
    }

    @Bean
    public ShortLinkTemplate shortLinkTemplate() throws ShortLinkException {
        return new ShortLinkTemplate(shortLinkConfiguration);
    }
}




